<%@ page contentType="text/html;charset=UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link rel="stylesheet" href="<%=basePath %>static/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="<%=basePath %>static/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="<%=basePath %>static/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="<%=basePath %>static/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="<%=basePath %>static/kindeditor/plugins/code/prettify.js"></script>
<script>
	var editor1,editor2,editor3,editor4;
	KindEditor.ready(function(K) {
		if($('textarea[name="content"]')){
			editor1 = K.create('textarea[name="content"]', {
				cssPath : '<%=basePath %>/static/kindeditor/plugins/code/prettify.css',
				uploadJson : '<%=basePath %>/kindeditor/upload',
				allowFileManager : false,
				allowImageRemote : false,
				formatUploadUrl : false,
				cssPath:"<%=basePath %>/static/front/css/kindeditoriframe-user.css",
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						//document.forms['example'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						//document.forms['example'].submit();
					});
				}
			});
			prettyPrint();
		}
		if($("#logo")){  //上传logo头像需要截取图片插件
			editor2 = K.editor({
				uploadJson : '<%=basePath %>/kindeditor/upload',
				allowFileManager : false,
				allowImageRemote : false,
				formatUploadUrl : false
			});
			
			K('#logoUpload').click(function() {
				editor2.loadPlugin('image', function() {
					editor2.plugin.imageDialog({
						imageUrl : K('#logo').attr("src"),
						showRemote : false,
						clickFn : function(url, title, width, height, border, align) {
							editor2.hideDialog();
							//打开截取图片插件
							avatarUploadMess_ShowDiv('avatarUpload_MyDiv','avatarUpload_fade',url);
						}
					});
				});
			});
		}
		if($("#photo")){
			editor3 = K.editor({
				uploadJson : '<%=basePath %>/kindeditor/upload',
				allowFileManager : false,
				allowImageRemote : false,
				formatUploadUrl : false
			});
			
			K('#photoUpload').click(function() {
				editor3.loadPlugin('image', function() {
					editor3.plugin.imageDialog({
						imageUrl : K('#photo').attr("src"),
						showRemote : false,
						clickFn : function(url, title, width, height, border, align) {
							editor3.hideDialog();
							showPhoto(url);
						}
					});
				});
			});
		}
		if(jQuery("#photos")){
			editor4 = K.editor({
				uploadJson : '<%=basePath %>/kindeditor/upload',
				allowFileManager : false,
				allowImageRemote : false,
				formatUploadUrl : false
			});
			
			jQuery("input[id='photoUploads']").each(function(){
				jQuery(this).click(function() {
					editor4.loadPlugin('image', function() {
						editor4.plugin.imageDialog({
							//imageUrl : K('#photos').attr("src"),
							showRemote : false,
							clickFn : function(url, title, width, height, border, align) {
								editor4.hideDialog();
								showPhotos(url);
							}
						});
					});
				});
			});
		}
		if($("#cutPhoto")){
			editor5 = K.editor({
				uploadJson : '<%=basePath %>/kindeditor/cutupload',
				allowFileManager : false,
				allowImageRemote : false,
				formatUploadUrl : false
			});
			
			K('#cutPhotoUpload').click(function() {
				editor5.loadPlugin('image', function() {
					editor5.plugin.imageDialog({
						imageUrl : K('#cutPhoto').attr("src"),
						showRemote : false,
						clickFn : function(url, title, width, height, border, align) {
							editor5.hideDialog();
							showPhoto(url);
						}
					});
				});
			});
		}
	});
</script>
<%@ include file="/WEB-INF/views/common/AvatarUpload.jsp"%>